<%@ page language="java" import="java.util.*,org.bean.Student;" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    
    <title>My JSP 'result.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <%request.setCharacterEncoding("utf-8"); %>
  <jsp:useBean id="data" class="org.database.DatabaseTool" scope="page" />
 <jsp:useBean id="students" class="org.bean.Student" scope="page" >
 <jsp:setProperty property="*" name="students"/>
 </jsp:useBean>
 <% String username=students.getUsername(); 
    String password=students.getPassword();
    String password1=students.getPassword1();
    String recordinfo=students.getRecordinfo();
    String studentname=students.getStudentname();
    String dormname=students.getDormname();
    String department=students.getDepartment() ;
    String profession=students.getProfession();
    String sex=students.getSex();
       if(!password.equals(password1)){
     out.print("<script>alert('两次输入的密码不一致');document.location='/MyChat/register.jsp'</script>");
       }else{
      if(username!=null&&password!=null&&recordinfo!=null&&studentname!=null&&dormname!=null&& department!=null&&profession!=null){
        boolean result=data.insertStudentInfo(username,password,recordinfo,studentname,dormname,department, profession,sex);
        if(result){
         out.print("<script>alert('注册成功');document.location='/MyChat/servlet/UserServlet'</script>");
        }else{
          out.print("<script>alert('注册失败');document.location='/MyChat/register.jsp'</script>");
        }
      }else{
         out.print("<script>alert('请输入完整的信息');document.location='/MyChat/register.jsp'</script>");
      }
      }
     %>
    
  </body>
</html>
